package com.springboot.controller.utils;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//Controller中一旦有异常就会进入该类
//处理异常
@RestControllerAdvice
public class ProjectExceptionAdvice {
    //拦截所有异常信息
    @ExceptionHandler(Exception.class)
    public R doException(Exception e){
        //异常在控制台打印
        e.printStackTrace();
        return new R("服务器故障，请稍后再试");
    }
}
